package com.biz.primus.ms.payment.service;

import com.biz.primus.common.utils.DateUtil;
import com.biz.primus.common.utils.JsonUtils;
import com.biz.primus.model.payment.vo.req.AllInPayPaymentNotifyReqVo;
import com.biz.primus.ms.base.service.AbstractBaseService;
import com.biz.primus.ms.payment.dao.po.AllInPayPaymentLogPo;
import com.biz.primus.ms.payment.dao.repository.AllInPayPaymentLogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * AllInPayPaymentLogService
 *
 * @author JKLiues
 * @date 2017年11月10日
 */
@Service
public class AllInPayPaymentLogService extends AbstractBaseService {

    @Autowired
    private AllInPayPaymentLogRepository allInPayPaymentLogRepository;

    /**
     * 记录通联支付日志
     */
    public void createLog(Long orderPaymentId, AllInPayPaymentNotifyReqVo reqVo) {
        AllInPayPaymentLogPo logPo = new AllInPayPaymentLogPo();
        logPo.setId(idService.getNextId());
        logPo.setLog(JsonUtils.obj2Json(reqVo));
        logPo.setOrderPaymentId(orderPaymentId);
        logPo.setTransactionId(reqVo.getChnltrxid());
        logPo.setTs(DateUtil.now());
        logPo.setOutTrxId(reqVo.getOuttrxid());
        logPo.setPayTime(reqVo.getPaytime());
        logPo.setTrxAmt(reqVo.getTrxamt());
        logPo.setTrxCode(reqVo.getTrxcode());
        logPo.setTrxDate(reqVo.getTrxdate());
        logPo.setTrxId(reqVo.getTrxid());
        logPo.setTrxStatus(reqVo.getTrxstatus());
        allInPayPaymentLogRepository.save(logPo);
    }
}